import time


def bsor(a):
    for i in range(len(a) - 1):
        for e in range(len(a) - i - 1):
            if a[e] > a[e + 1]:
                a[e], a[e + 1] = a[e + 1], a[e]


def rd(b):
    fil = open(b)
    d = fil.readlines()
    return d


t1 = rd('m1_sorted.txt')
t2 = rd('m2_reverse.txt')
t3 = rd('m3_shuffle.txt')

st = time.time()
bsor(t1)
fin = time.time()
print('m1_sorted', round((fin - st) * 1000), 'milliseconds')

st = time.time()
bsor(t2)
fin = time.time()
print('m2_reverse', round((fin - st) * 1000), 'milliseconds')

st = time.time()
bsor(t3)
fin = time.time()
print('m3_shuffle', round((fin - st) * 1000), 'milliseconds')
